package com.et114.components.acegi.acl.voter;

import org.acegisecurity.vote.BasicAclEntryVoter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.et114.components.acegi.acl.AclUtils;

/**
 * 扩展了BasicAclEntryVoter，对于拦截方法中的参数仅仅为id的情况作了处理。
 * @author guanhw
 * @see AclUtils#getDomainObjectInstance(Object, Class)
 * @see BasicAclEntryVoter
 */
public class IdParameterAclEntryVoter extends BasicAclEntryVoter {

	// ~ Static fields/initializers
	// =============================================

	private static final Log	logger	= LogFactory.getLog( IdParameterAclEntryVoter.class );

	// ~ Instance fields
	// ========================================================

	private Class				domainClass;

	private String				methodDomainObjectClass;

	protected Object getDomainObjectInstance ( Object secureObject ) {
		logger.info( "!!" ) ;
		return AclUtils.getDomainObjectInstance( secureObject,
				methodDomainObjectClass, domainClass );
	}

	public Class getDomainClass ( ) {
		return domainClass;
	}

	public void setDomainClass ( Class domainClass ) {
		this.domainClass = domainClass;
	}

	public String getMethodDomainObjectClass ( ) {
		return methodDomainObjectClass;
	}

	public void setMethodDomainObjectClass ( String methodDomainObjectClass ) {
		this.methodDomainObjectClass = methodDomainObjectClass;
	}
}
